import 'dart:async';

import 'package:flutter_test/flutter_test.dart';

void main() {
  test("loadDataTimeout", () async {
    Future<String> loadDataFuture = loadData();
    try {
      String data = await loadDataFuture.timeout(Duration(seconds: 10));
      print("data $data");
    } on TimeoutException catch(e) {
      print("load data timeout");
    }
  });

  test("voidTest", () async {
    var t = doFunction(voidTest);
    if (t is Future) {
      Future f = t as Future;
      var r = await f;
      print(r == null);
    }
    print(t is Future);
  });
}

Future<String> loadData() async {
  await Future.delayed(Duration(seconds: 1));
  return "hello world";
}

dynamic doFunction(Function function) {
  return function();
}

void voidTest() async {
  await loadData();
}